import { Controller, Post, Get, Body, Param, Query } from '@nestjs/common';
import { GenerationService } from './generation.service';

@Controller('generation')
export class GenerationController {
    constructor(private readonly generationService: GenerationService) { }

    @Post()
    async generate(
        @Body('templateId') templateId: string,
        @Body('params') params: any,
        @Body('userId') userId?: string,
    ) {
        return this.generationService.generate(templateId, params, userId);
    }

    @Post('save')
    async saveResult(
        @Body('imageUrl') imageUrl: string,
        @Body('templateId') templateId: string,
        @Body('params') params: any,
        @Body('userId') userId?: string,
    ) {
        return this.generationService.saveResult(imageUrl, templateId, params, userId);
    }

    @Get()
    async getResults(
        @Query('userId') userId?: string,
        @Query('page') page?: number,
        @Query('limit') limit?: number,
    ) {
        return this.generationService.getResults(userId, page, limit);
    }
} 